<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr =[6,8,4,9,3]
        console.log(arr)
        for(var i=0;i<arr.length;i++){
           var x =arr[i]; //具体的值
           var xIndex =i; //储存索引
            for(var j=i+1;j<arr.length;j++){
                if(x>arr[j]){
                    x=arr[j]
                    xIndex=j
                }
            }
            arr[xIndex]=arr[i]
            arr[i]=x
        }
       console.log(arr)
    </script>
</body>
</html>